import java.util.Arrays;

public class maopao {
    public static void main(String[] args) {
        int [] array = new int[]{5,8,6,3,9,2,1,7};
        sort(array);
        System.out.println(Arrays.toString(array));
    }


    public static void sort(int array[]){
        for (int i = 0; i < array.length-1; i++) {
            System.out.println("外循环"+i+"轮"+ Arrays.toString(array));
            for (int j = 0; j < array.length-i-1; j++) {
                int tep = 0;
                System.out.println("内循环"+i+"轮"+ Arrays.toString(array));
              if (array[j]>array[j+1]){
                   tep=array[j];
                  array[j] = array[j+1];
                  array[j+1]=tep;
              }
            }
        }
    }
}
